package com.ccom.test.controller;

import com.ccom.core.common.constant.ServiceNameConstants;
import com.ccom.core.common.model.BaseMap;
import com.ccom.core.common.model.Result;
import com.ccom.redis.client.CcomRedisClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description:
 * @author: jjzhang24
 * @date: 2022年01月12日
 */
@Slf4j
@Api(tags = "redis 测试")
@RestController
@RequestMapping(ServiceNameConstants.TEST_SERVICE_URL_PREFIX + "/redis")
public class RedisController {

    @Autowired
    private CcomRedisClient ccomRedisClient;

    @ApiOperation(value = "测试RedisReceiver消息通道")
    @GetMapping("/sendToRedisReceiver")
    public Result sendToRedisReceiver(@RequestParam(value = "handlerName", required = false) String handlerName, @RequestParam(value = "message")String message){
        ccomRedisClient.sendMessage(handlerName,new BaseMap().put("message",message));
        return Result.success();
    }
}
